﻿<%@ Page Language="C#" MasterPageFile="~/MangerPage.master" AutoEventWireup="true" CodeFile="Manger_Courses.aspx.cs" Inherits="Manger_Courses" Title="课程管理" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<div class="pagetitle">课程列表</div>
    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="Course_ID" DataSourceID="SqlDataSource1" Width="90%" OnRowCommand="GridView1_RowCommand">
        <RowStyle HorizontalAlign="Center" VerticalAlign="Middle" />
        <Columns>
            <asp:BoundField DataField="Course_ID" HeaderText="课程ID" InsertVisible="False" ReadOnly="True"
                SortExpression="Course_ID" />
            <asp:BoundField DataField="Course_Name" HeaderText="课程名称" SortExpression="Course_Name" />
            <asp:TemplateField>
                <EditItemTemplate>
                    <asp:LinkButton ID="LinkButton4" runat="server" CommandName="Update">确定</asp:LinkButton>
                    &nbsp;
                    <asp:LinkButton ID="LinkButton5" runat="server" CommandName="Cancel">取消</asp:LinkButton>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:LinkButton ID="LinkButton1" runat="server" CommandName="Edit">编辑</asp:LinkButton>
                    &nbsp; &nbsp;
                    <asp:LinkButton ID="LinkButton2" runat="server" CommandName="Insert">添加</asp:LinkButton>
                    &nbsp; &nbsp;
                    <asp:LinkButton ID="LinkButton3" runat="server" CommandName="Delete" OnClientClick="return confirm('确定删除此课程？')">删除</asp:LinkButton>
                </ItemTemplate>
            </asp:TemplateField>
        </Columns>
        <EmptyDataTemplate>
            <asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" DataKeyNames="Course_ID"
                DataSourceID="SqlDataSource1" DefaultMode="Insert" Height="62px" Width="100%" OnItemInserted="DetailsView1_ItemInserted">
                <FooterStyle HorizontalAlign="Center" />
                <FooterTemplate>
                    <asp:LinkButton ID="LinkButton6" runat="server" CommandName="Insert">确定</asp:LinkButton>&nbsp;
                    <asp:LinkButton ID="LinkButton7" runat="server" CommandName="Cancel">取消</asp:LinkButton>
                </FooterTemplate>
                <Fields>
                    <asp:BoundField DataField="Course_ID" HeaderText="Course_ID" InsertVisible="False"
                        ReadOnly="True" SortExpression="Course_ID" />
                    <asp:BoundField DataField="Course_Name" HeaderText="课程名称：" SortExpression="Course_Name">
                        <HeaderStyle HorizontalAlign="Right" />
                    </asp:BoundField>
                </Fields>
            </asp:DetailsView>
        </EmptyDataTemplate>
    </asp:GridView>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:Jxzy_Database %>"
        SelectCommand="SELECT [Course_ID], [Course_Name] FROM [zyk_Courses] WHERE ([Course_MajorID] = @Course_MajorID)" DeleteCommand="DELETE FROM [zyk_Courses] WHERE [Course_ID] = @Course_ID" InsertCommand="INSERT INTO [zyk_Courses] ([Course_Name],[Course_MajorID]) VALUES (@Course_Name,@Course_MajorID)" UpdateCommand="UPDATE [zyk_Courses] SET [Course_Name] = @Course_Name WHERE [Course_ID] = @Course_ID">
        <SelectParameters>
            <asp:Parameter Name="Course_MajorID" />
        </SelectParameters>
        <DeleteParameters>
            <asp:Parameter Name="Course_ID" Type="Int32" />
        </DeleteParameters>
        <UpdateParameters>
            <asp:Parameter Name="Course_Name" Type="String" />
            <asp:Parameter Name="Course_ID" Type="Int32" />
        </UpdateParameters>
        <InsertParameters>
            <asp:Parameter Name="Course_Name" Type="String" />
        </InsertParameters>
    </asp:SqlDataSource>
</asp:Content>

